package bio;

import common.ProcessUtil;

import java.io.IOException;
import java.io.InputStream;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.TimeUnit;

/**
 * program: io-share 
 * author: bsworld.xie 
 * create: 2021-04-07 19:46 
 * description: 
 */
public class BioServer {
    public static void main(String[] args) throws IOException, InterruptedException {
        System.out.println("BioServer,当前进程pid是:"+ ProcessUtil.getPid());
        int port = 2888;
        ServerSocket ss = new ServerSocket();
        System.out.println("BioServer, 监听的端口号是:" + port);
        ss.bind(new InetSocketAddress(port));
        int i = 0;
        while (true) {
            Socket clientSocket = ss.accept();
//            System.out.println("接收到第" + i + "个链接, clientSocket:" + clientSocket);
//            byte[] readArr = new byte[1024];
////            clientSocket.getInputStream().read(readArr);
//            clientSocket.getInputStream().read();
//            System.out.println("接收到新的消息");
//            String msg = new String(readArr);
//            System.out.println("接收到客户端的消息， msg is:" + msg);
            i++;
        }
    }
}
